﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using dbcntn;

namespace Campus.Main.Basic.InsertValues
{
    public partial class MaddeBend : Default
    {
        public MaddeBend()
        {
            InitializeComponent();
            aToDb=new ConnectionToDb(Helper.ConnectionString);
            aToDb.AddItem(comboBox1,"maddeno");
            button1.Click += button1_Click;
        }

        public MaddeBend(List<string> item):base(item)
        {
            InitializeComponent();
            aToDb = new ConnectionToDb(Helper._connectionString);
            aToDb.AddItem(comboBox1, "maddeno");
            comboBox1.SelectedValue = item[1];
            textBox1.Text = item[2];
            textBox2.Text = item[3];
            button1.Click += button1_Click_1;
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0)
            {
                string s = Convert.ToString(comboBox1.SelectedValue);
                aToDb.UpdateTableMaddeBend(s,textBox1.Text.Trim(),textBox2.Text,id);
                Close();
            }
            else
            {
                MessageBox.Show("Талааларды толтургула!!!");
            }
        }

        protected override void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length>0&&textBox2.Text.Length>0)
            {
                string s = Convert.ToString(comboBox1.SelectedValue);
                aToDb.InsertIntoMaddeBend(s,textBox1.Text.Trim(),textBox2.Text);
                MessageBox.Show("Eklendi");
                textBox1.Clear();
                textBox2.Clear();
            }
            else
            {
                MessageBox.Show("Талааларды толтургула!!!");
            }
        }
    }
}
